package com.robotic.device.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.robotic.common.annotation.Log;
import com.robotic.common.core.controller.BaseController;
import com.robotic.common.core.domain.AjaxResult;
import com.robotic.common.enums.BusinessType;
import com.robotic.device.domain.DeviceCheckResults;
import com.robotic.device.service.IDeviceCheckResultsService;
import com.robotic.common.utils.poi.ExcelUtil;
import com.robotic.common.core.page.TableDataInfo;

/**
 * 检测结果管理Controller
 *
 * @author tian
 * @date 2025-09-30
 */
@RestController
@RequestMapping("/admin/check")
public class DeviceCheckResultsController extends BaseController
{
    @Autowired
    private IDeviceCheckResultsService deviceCheckResultsService;

    /**
     * 查询检测结果管理列表
     */
    @PreAuthorize("@ss.hasPermi('admin:check:list')")
    @GetMapping("/list")
    public TableDataInfo list(DeviceCheckResults deviceCheckResults)
    {
        startPage();
        List<DeviceCheckResults> list = deviceCheckResultsService.selectDeviceCheckResultsList(deviceCheckResults);
        return getDataTable(list);
    }

    /**
     * 导出检测结果管理列表
     */
    @PreAuthorize("@ss.hasPermi('admin:check:export')")
    @Log(title = "检测结果管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DeviceCheckResults deviceCheckResults)
    {
        List<DeviceCheckResults> list = deviceCheckResultsService.selectDeviceCheckResultsList(deviceCheckResults);
        ExcelUtil<DeviceCheckResults> util = new ExcelUtil<DeviceCheckResults>(DeviceCheckResults.class);
        util.exportExcel(response, list, "检测结果管理数据");
    }

    /**
     * 获取检测结果管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('admin:check:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(deviceCheckResultsService.selectDeviceCheckResultsById(id));
    }

    /**
     * 新增检测结果管理
     */
    @PreAuthorize("@ss.hasPermi('admin:check:add')")
    @Log(title = "检测结果管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DeviceCheckResults deviceCheckResults)
    {
        return toAjax(deviceCheckResultsService.insertDeviceCheckResults(deviceCheckResults));
    }

    /**
     * 修改检测结果管理
     */
    @PreAuthorize("@ss.hasPermi('admin:check:edit')")
    @Log(title = "检测结果管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DeviceCheckResults deviceCheckResults)
    {
        return toAjax(deviceCheckResultsService.updateDeviceCheckResults(deviceCheckResults));
    }

    /**
     * 删除检测结果管理
     */
    @PreAuthorize("@ss.hasPermi('admin:check:remove')")
    @Log(title = "检测结果管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(deviceCheckResultsService.deleteDeviceCheckResultsByIds(ids));
    }
}
